package com.emr.web.controller.emr;


import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.emr.common.annotation.Log;
import com.emr.common.enums.BusinessType;
import com.emr.module.domain.Linchuanglujing;
import com.emr.module.service.ILinchuanglujingService;
import com.emr.web.core.base.BaseController;
import com.emr.framework.web.page.TableDataInfo;
import com.emr.common.base.AjaxResult;

/**
 * 临床路径 信息操作处理
 * 
 * @author emr
 * @date 2019-03-01
 */
@Controller
@RequestMapping("/module/linchuanglujing")
public class LinchuanglujingController extends BaseController
{
    private String prefix = "module/linchuanglujing";
	
	@Autowired
	private ILinchuanglujingService linchuanglujingService;
	
	@RequiresPermissions("module:linchuanglujing:view")
	@GetMapping()
	public String linchuanglujing()
	{
	    return prefix + "/linchuanglujing";
	}
	
	/**
	 * 查询临床路径列表
	 */
	@RequiresPermissions("module:linchuanglujing:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Linchuanglujing linchuanglujing)
	{
		startPage();
        List<Linchuanglujing> list = linchuanglujingService.selectLinchuanglujingList(linchuanglujing);
		return getDataTable(list);
	}
	
	/**
	 * 新增临床路径
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存临床路径
	 */
	@RequiresPermissions("module:linchuanglujing:add")
	@Log(title = "临床路径", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Linchuanglujing linchuanglujing)
	{		
		return toAjax(linchuanglujingService.insertLinchuanglujing(linchuanglujing));
	}

	/**
	 * 修改临床路径
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Linchuanglujing linchuanglujing = linchuanglujingService.selectLinchuanglujingById(id);
		System.out.println(linchuanglujing.getChangguiyiliao());
		mmap.put("linchuanglujing", linchuanglujing);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存临床路径
	 */
	@RequiresPermissions("module:linchuanglujing:edit")
	@Log(title = "临床路径", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Linchuanglujing linchuanglujing)
	{		
		return toAjax(linchuanglujingService.updateLinchuanglujing(linchuanglujing));
	}
	
	/**
	 * 删除临床路径
	 */
	@RequiresPermissions("module:linchuanglujing:remove")
	@Log(title = "临床路径", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(linchuanglujingService.deleteLinchuanglujingByIds(ids));
	}
	
}
